class Context:
    def do_something(self):
        pass
    
    def __enter__(self):
        return self
    
    def __exit__(self,exc_type,exc_val,exc_tb):
        pass

with Context() as f:
    f.do_something()